<script>
  export default{
    name:'StudentComponent',
    props:['name', 'age', 'sex'],
    data(){
      return {
        msg: "我是一名学生",
        studentAge: this.age,
      }
    },
    methods:{
      updateAge() {
        console.log(this.studentAge)
        return this.studentAge++
      }
    }
  }
</script>

<template>
  <div>
    <h1>{{msg}}</h1>
    <h3>学生姓名: {{name}}</h3>
    <h3>年龄: {{studentAge}}</h3>
    <h3>性别: {{sex}}</h3>
    <button @click="updateAge">尝试修改收到的年龄</button>
  </div>
</template>

<style scoped>

</style>